// test/test_rt_odd_check.c

#include "unity.h"
#include "xrt1553B.h"

// Since the function is static, we need to either make it non-static for testing
// or include the source file directly. Here I'll assume we make it non-static
// or use a test-specific header that exposes it.
extern u32 Rt_odd_check(u32 RT_address);

void setUp(void)
{
    // Set up before each test case
}

void tearDown(void)
{
    // Clean up after each test case
}

void test_Rt_odd_check_ZeroAddress_ReturnsShiftedValueWithParityBitSet(void)
{
    // Test case: 0x00000000 -> 0 bits set (even) -> parity bit = 1
    // Expected: (0 << 1) | 1 = 1
    TEST_ASSERT_EQUAL_HEX32(0x00000001, Rt_odd_check(0x00000000));
}

void test_Rt_odd_check_OneBitSet_ReturnsShiftedValueWithParityBitClear(void)
{
    // Test case: 0x00000001 -> 1 bit set (odd) -> parity bit = 0
    // Expected: (1 << 1) | 0 = 2
    TEST_ASSERT_EQUAL_HEX32(0x00000002, Rt_odd_check(0x00000001));
}

void test_Rt_odd_check_TwoBitsSet_ReturnsShiftedValueWithParityBitSet(void)
{
    // Test case: 0x00000003 -> 2 bits set (even) -> parity bit = 1
    // Expected: (3 << 1) | 1 = 7
    TEST_ASSERT_EQUAL_HEX32(0x00000007, Rt_odd_check(0x00000003));
}

void test_Rt_odd_check_ThreeBitsSet_ReturnsShiftedValueWithParityBitClear(void)
{
    // Test case: 0x00000007 -> 3 bits set (odd) -> parity bit = 0
    // Expected: (7 << 1) | 0 = 14
    TEST_ASSERT_EQUAL_HEX32(0x0000000E, Rt_odd_check(0x00000007));
}

void test_Rt_odd_check_FourBitsSet_ReturnsShiftedValueWithParityBitSet(void)
{
    // Test case: 0x0000000F -> 4 bits set (even) -> parity bit = 1
    // Expected: (15 << 1) | 1 = 31
    TEST_ASSERT_EQUAL_HEX32(0x0000001F, Rt_odd_check(0x0000000F));
}

void test_Rt_odd_check_FiveBitsSet_ReturnsShiftedValueWithParityBitClear(void)
{
    // Test case: 0x0000001F -> 5 bits set (odd) -> parity bit = 0
    // Expected: (31 << 1) | 0 = 62
    TEST_ASSERT_EQUAL_HEX32(0x0000003E, Rt_odd_check(0x0000001F));
}

void test_Rt_odd_check_AddressWithHighBitsSet_ReturnsCorrectValue(void)
{
    // Test case: 0xFFFFFFFF -> masked to 0x1F (5 bits set, odd) -> parity bit = 0
    // Expected: (31 << 1) | 0 = 62
    TEST_ASSERT_EQUAL_HEX32(0x0000003E, Rt_odd_check(0xFFFFFFFF));
}

void test_Rt_odd_check_AlternatingPattern_ReturnsCorrectValue(void)
{
    // Test case: 0x00000015 (binary: 10101) -> 3 bits set (odd) -> parity bit = 0
    // Expected: (21 << 1) | 0 = 42
    TEST_ASSERT_EQUAL_HEX32(0x0000002A, Rt_odd_check(0x00000015));
}

void test_Rt_odd_check_EvenParityPattern_ReturnsCorrectValue(void)
{
    // Test case: 0x0000000A (binary: 01010) -> 2 bits set (even) -> parity bit = 1
    // Expected: (10 << 1) | 1 = 21
    TEST_ASSERT_EQUAL_HEX32(0x00000015, Rt_odd_check(0x0000000A));
}